import myAxios from "../plugins/MyAxios.ts";

/**
 * 获取团队列表
 */
export const getTeamList = (val: string, status: number) => myAxios.get('/team/list', {
    params: {
        page: 1,
        searchText: val,
        status,
    }
})

/**
 * 新增团队
 * @param postData
 */
export const saveTeam = (postData: any) => myAxios.post('/team/save', postData);

/**
 * 修改团队信息
 * @param postData
 */
export const updateTeam = (postData: any) => myAxios.put('/team/update', postData)

/**
 * 根据id查询队伍信息
 * @param id
 */
export const getTeamById = (id: number) => myAxios.get(`/team/list/${id}`);

/**
 * 获取当前用户创建团队列表
 */
export const getTeamCurrentCreateList = (val: string) => myAxios.get('/team/list/current/create', {
    params: {
        page: 1,
        searchText: val,
    }
})

/**
 * 获取团队列表
 */
export const getTeamCurrentJoinList = (val: string) => myAxios.get('/team/list/current/join', {
    params: {
        page: 1,
        searchText: val,
    }
})

/**
 * 加入队伍
 * @param teamId
 * @param password
 */
export const joinTeam = (teamId: number, password: string) => myAxios.post('/team/join', {
    id: teamId,
    password: password,
});

/**
 * 退出队伍
 * @param id
 */
export const quitTeam = (id: number) => myAxios.delete(`/team/quit/${id}`);

/**
 * 解散队伍
 * @param id
 */
export const deleteTeam = (id: number) => myAxios.delete(`/team/delete/${id}`);